package cn.ztelovecly.springboot.bussiness.controller;

import cn.ztelovecly.springboot.contract.request.UserCreateRequest;
import cn.ztelovecly.springboot.contract.response.UserCreateResponse;
import cn.ztelovecly.springboot.contract.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by zhaotianen on 2017/2/18.
 */
@RestController
@RequestMapping(value = "/api/user")
public class UserController {
    @Autowired
    private UserService userService;

    @ApiOperation(value = "增加", notes = "必须传入对象")
    @RequestMapping(value = "/insert", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public UserCreateResponse insert(@ModelAttribute(value = "request") UserCreateRequest request) {
        UserCreateResponse response = new UserCreateResponse();
        response = userService.createUser(request);
        return response;
    }
}
